import EE from '../components/designer/form/script-code/edc-form/event';
import _ from 'lodash';

export const emit = (evtName) => {
  const eventHandler = EE.listeners(evtName)[0];
  let result = null;

  if (_.isFunction(eventHandler)) {
    result = eventHandler();
  }

  return new Promise((resolve) => {
    if (result && result.then) {
      result.then(resolve)
    } else {
      resolve(result);
    }
  });
}